package com.yami.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.yami.bean.AdminUser;
import com.yami.service.AdminService;

@Controller
public class AdminLoginController {

	@Autowired
	AdminService adminService;

	@RequestMapping("/adminlogin")
	public String adminLogin(String username, String password, String inputtest) {
		// TODO Auto-generated method stub
		System.out.println("login");
		ModelAndView retMap = new ModelAndView();
		retMap.setViewName("test");
		System.out.println("username=" + username);
		System.out.println("password=" + password);
		System.out.println("inputtest=" + inputtest);
		List<AdminUser> adminUsers = adminService.testLogin(username, password);
		if (adminUsers.isEmpty())
			return "Login Falure!";
		return "addgoods";

	}

	@RequestMapping("/login")
	@ResponseBody
	public String login(String username, String password) {
		// TODO Auto-generated method stub
		System.out.println("login");
		ModelAndView retMap = new ModelAndView();
		retMap.setViewName("test");

		System.out.println("username=" + username);
		System.out.println("password=" + password);
		return "test";
	}

	@RequestMapping("/admin")
	public String admin() {
		// TODO Auto-generated method stub
		System.out.println("admin");
		return "login";
	}

	@RequestMapping("/addgoodss")
	@ResponseBody
	// public String addGoods(HttpServletRequest req, HttpServletResponse
	// response) {
	public String addGoods() {
		// TODO Auto-generated method stub
		System.out.println("addgoods");
		// System.out.println("first:" + req.getParameter("title1"));
		// System.out.println("second:" + req.getParameterValues("title1"));
		return "addgoods";
	}
}